<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>验证码</title>
<link href="/AjaxAut/layui/css/layui.css" rel="stylesheet" type="text/css">
<script src="/AjaxAut/layui/layui.all.js" type="text/javascript"></script>
</head>
<body>
	<form class="layui-form-pane layui-form">
		<div class="layui-form-item">
			<label class="layui-form-label"> 
			<img src="/AjaxAut/AuthCodeServlet"
				onclick='this.src="/AjaxAut/AuthCodeServlet?"+Math.random()' />
			</label>
			<div class="layui-input-inline">
				<input class="layui-input" name="authCode" type="text"
					placeholder="请输入验证码" required lay-verify="required"
					autocomplete="off">
			</div>
			<div class="layui-input-inline">
				<input type="button" value="确定" class="layui-btn" lay-submit lay-filter="but" /> 
				<input type="reset" value="重置" class="layui-btn layui-btn-primary" />
			</div>
			<input type="hidden" name="action" value="log" />
		</div>
	</form>
	
	<script type="text/javascript">
	var form = layui.form;
	var $ = layui.jquery;
	var layer = layui.layer;
	
	form.on('submit(but)',function(data){
		console.log(data.field)
		$.ajax({
			type:"post",
			data:data.field,
			url:'/AjaxAut/authcode',
			dataType:"text",
			success:function(data){
				console.log(data)
				if("N"==data){
					layer.msg("验证失败");
				}else{
					layer.msg("验证成功");
				}
			}
		});
	})
	
	</script>
</body>
</html>